import request from '@/utils/require'
function login(data){
    return   request({
        'url':'/rear-end/admin/login',
        'method': 'POST',
        data
    })
}
function logout(){
    return request({
        'url':'/rear-end/admin/logout',
        'method': 'GET',  
    })
}
function test(){
    return   request({
        'url':'/rear-end/admin/test',
        'method': 'GET',  
    })
}
//用户查询
function allAdmin(data){
    return   request({
        'url':'/rear-end/admin/selectAllAdmin',
        'method': 'GET',
        "params":data
    })
}
function selectAdmin(data){
    return   request({
        'url':'/rear-end/admin/selectAdmin',
        'method': 'POST',
        data
    })
}
function addAdmin(data){
    return   request({
        'url':'/rear-end/admin/addAdmin',
        'method': 'POST',
        data
    })
}
function updateAdmin(data){
    return   request({
        'url':'/rear-end/admin/updateAdmin',
        'method': 'POST',
        data
    })
}
function delAdmin(data){
    return   request({
        'url':'/rear-end/admin/delAdmin',
        'method': 'get',
        "params":data
    })
}
//分类查询
function categories(data){
    return   request({
        'url':'/rear-end/cat/categories',
        'method': 'get',
        "params":data
    })
}
function addCate(data){
    return   request({
        'url':'/rear-end/cat/addCat',
        'method': 'POST',
        data
    })
}
function updateCate(data){
    return   request({
        'url':'/rear-end/cat/updateCat',
        'method': 'POST',
        data
    })
}
function delCate(data){
    return   request({
        'url':'/rear-end/cat/delCat',
        'method': 'get',
        "params":data
    })
}
//分类参数
function attributes(data,id){
    return   request({
        'url':`/rear-end/attr/${id}/attributes`,
        'method': 'get',
        "params":data
    })
}
function addattr(data){
    return   request({
        'url':`/rear-end/attr/addAttr`,
        'method': 'post',
        data
    })

}
function editattr(data){
    return   request({
        'url':`/rear-end/attr/editAttr`,
        'method': 'put',
        data
    })
}
function delattr(data){
    return   request({
        'url':'/rear-end/attr/delAttr',
        'method': 'get',
        "params":data
    })
}
// 商品操作
function goods(data){
    return   request({
        'url':'/rear-end/goods',
        'method': 'get',
        "params":data
    })
}
function addGodds(data){
    return request({
        'url':'/rear-end/addGoods',
        'method': 'post',
        data
    })
}
function delGoods(data){
    return   request({
        'url':'/rear-end/delGoods',
        'method': 'delete',
        "params":data
    })
}
function updateGoods(data){
    return   request({
        'url':'/rear-end/updateGoods',
        'method': 'put',
        data
    })
}
function download( data){
    return   request({
        'url':`/rear-end/common/download?name=${data}`,
        'method': 'get',
        'responseType':'blob'
    })
}
// 商品购物车
function allCart(data){
    return   request({
        'url':`/shoppingCart/allCart`,
        'method': 'get',
        "params":data
    })
}
function addCart(data){
    return request({
        'url':'/shoppingCart/addCart',
        'method': 'post',
        data
    })
}
function editCart(data){
    return request({
        'url':'/shoppingCart/editCart',
        'method': 'put',
        data
    })
}
function delCart(data){
    return request({
        'url':'/shoppingCart/delCart',
        'method': 'delete',
        "params":data
    })
}
// 购买操作
function addOrders(data){
    return request({
        'url':'/orders/addOrders',
        'method': 'post',
        data
    })
}
function allOrders(data){
    return   request({
        'url':`/orders/allOrders`,
        'method': 'get',
        "params":data
    })
}
function getOrders(data){
    return   request({
        'url':`/orders/getOrders`,
        'method': 'post',
        data
    })
}
function isdel(data){
    return request({
        'url':'/orders/editOrders',
        'method': 'put',
        data
    })
}
// 评价功能
function saveEvca(data){
    return request({
        'url':'/rear-end/saveEvca',
        'method': 'post',
        data
    })
}
function getEva(data){
        return   request({
            'url':`/rear-end/getEva`,
            'method': 'get',
            "params":data
        })
}
export default{
    //用户登录
    login,test,logout,
    //账号操作
    addAdmin,updateAdmin,delAdmin,selectAdmin,allAdmin,
    // 分类操作
    categories,addCate,updateCate,delCate,
    //    分类参数操作
    attributes,addattr,editattr,delattr,
    // 商品操作
    goods,delGoods,addGodds,updateGoods,
    download,
    allCart,addCart,editCart,delCart,
    addOrders,allOrders,getOrders,isdel,saveEvca,getEva
}